| Conditions | 1 |
| Paths | 2 |
| Total Lines | 90 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 6 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | |||
| 18 | class SecurityAdminSettings |
||
| 19 | { |
||
| 20 | constructor() { |
||
| 21 | this.useLocalProxyForExternalImages = AppAdminStore.useLocalProxyForExternalImages; |
||
| 22 | |||
| 23 | this.weakPassword = AppAdminStore.weakPassword; |
||
| 24 | |||
| 25 | this.capaOpenPGP = CapaAdminStore.openPGP; |
||
| 26 | |||
| 27 | this.capaTwoFactorAuth = CapaAdminStore.twoFactorAuth; |
||
| 28 | this.capaTwoFactorAuthForce = CapaAdminStore.twoFactorAuthForce; |
||
| 29 | |||
| 30 | this.capaTwoFactorAuth.subscribe((value) => { |
||
| 31 | if (!value) |
||
| 32 | { |
||
| 33 | this.capaTwoFactorAuthForce(false); |
||
| 34 | } |
||
| 35 | }); |
||
| 36 | |||
| 37 | this.verifySslCertificate = ko.observable(!!settingsGet('VerifySslCertificate')); |
||
| 38 | this.allowSelfSigned = ko.observable(!!settingsGet('AllowSelfSigned')); |
||
| 39 | |||
| 40 | this.verifySslCertificate.subscribe((value) => { |
||
| 41 | if (!value) |
||
| 42 | { |
||
| 43 | this.allowSelfSigned(true); |
||
| 44 | } |
||
| 45 | }); |
||
| 46 | |||
| 47 | this.isTwoFactorDropperShown = ko.observable(false); |
||
| 48 | this.twoFactorDropperUser = ko.observable(''); |
||
| 49 | this.twoFactorDropperUser.focused = ko.observable(false); |
||
| 50 | |||
| 51 | this.adminLogin = ko.observable(settingsGet('AdminLogin')); |
||
| 52 | this.adminLoginError = ko.observable(false); |
||
| 53 | this.adminPassword = ko.observable(''); |
||
| 54 | this.adminPasswordNew = ko.observable(''); |
||
| 55 | this.adminPasswordNew2 = ko.observable(''); |
||
| 56 | this.adminPasswordNewError = ko.observable(false); |
||
| 57 | |||
| 58 | this.adminPasswordUpdateError = ko.observable(false); |
||
| 59 | this.adminPasswordUpdateSuccess = ko.observable(false); |
||
| 60 | |||
| 61 | this.adminPassword.subscribe(() => { |
||
| 62 | this.adminPasswordUpdateError(false); |
||
| 63 | this.adminPasswordUpdateSuccess(false); |
||
| 64 | }); |
||
| 65 | |||
| 66 | this.adminLogin.subscribe(() => { |
||
| 67 | this.adminLoginError(false); |
||
| 68 | }); |
||
| 69 | |||
| 70 | this.adminPasswordNew.subscribe(() => { |
||
| 71 | this.adminPasswordUpdateError(false); |
||
| 72 | this.adminPasswordUpdateSuccess(false); |
||
| 73 | this.adminPasswordNewError(false); |
||
| 74 | }); |
||
| 75 | |||
| 76 | this.adminPasswordNew2.subscribe(() => { |
||
| 77 | this.adminPasswordUpdateError(false); |
||
| 78 | this.adminPasswordUpdateSuccess(false); |
||
| 79 | this.adminPasswordNewError(false); |
||
| 80 | }); |
||
| 81 | |||
| 82 | this.onNewAdminPasswordResponse = _.bind(this.onNewAdminPasswordResponse, this); |
||
| 83 | } |
||
| 84 | |||
| 85 | @command((self) => '' !== trim(self.adminLogin()) && '' !== self.adminPassword()) |
||
| 86 | saveNewAdminPasswordCommand() { |
||
| 87 | |||
| 88 | if ('' === trim(this.adminLogin())) |
||
| 89 | { |
||
| 90 | this.adminLoginError(true); |
||
| 91 | return false; |
||
| 92 | } |
||
| 93 | |||
| 94 | if (this.adminPasswordNew() !== this.adminPasswordNew2()) |
||
| 95 | { |
||
| 96 | this.adminPasswordNewError(true); |
||
| 97 | return false; |
||
| 98 | } |
||
| 99 | |||
| 100 | this.adminPasswordUpdateError(false); |
||
| 101 | this.adminPasswordUpdateSuccess(false); |
||
| 102 | |||
| 103 | Remote.saveNewAdminPassword(this.onNewAdminPasswordResponse, { |
||
| 104 | 'Login': this.adminLogin(), |
||
| 105 | 'Password': this.adminPassword(), |
||
| 106 | 'NewPassword': this.adminPasswordNew() |
||
| 107 | }); |
||
| 108 | |||
| 195 |